<?php 
$object=$this->object;
$imageurl=$this->imageurl;

defined('_JEXEC') or die('Restricted access');

AdminUIHelper::startAdminArea ();
?>
<script type="text/javascript">

function CheckMail(email) {
	var rs = new RegExp("([A-Za-z0-9_.-]){2,}@([A-Za-z0-9_.-]){2,}.([A-Za-z0-9_.-]){2,}");
	if(email.match(rs) == null) return 0;
	return 1;
}
function limiter(){
	// check name blank
	var name= document.adminForm.dvql_ten.value;
	if(name=="") document.getElementById('loiten').innerHTML="(!)  Not blank.!";
	else  document.getElementById('loiten').innerHTML="";
	// check adress blank
	var diachi= document.adminForm.dvql_diachi.value;
	if(diachi=="") document.getElementById('loidiachi').innerHTML="(!) Not blank.!";
	else  document.getElementById('loidiachi').innerHTML="";
	// check phone number parseInt
		var phone= document.adminForm.dvql_dienthoai.value;
		var lgt=phone.length;
		var er=1;
		phone=parseInt(phone);
	if(phone==0) er=0;
	if(phone.toString()=='NaN') er=0;
	if(lgt<10||lgt>11) er=0;
	if(er==0) document.getElementById('loiphone').innerHTML="(!) Just a phone number.!";
	else  document.getElementById('loiphone').innerHTML='';
	// check mail
	var mail= document.adminForm.dvql_email.value;
		check=CheckMail(mail);
	if(check==0) document.getElementById('loi').innerHTML="(!)  Just a valide email.!";
	else document.getElementById('loi').innerHTML="";
	// count text comment
	var tex = document.adminForm.dvql_mieuta.value;
	var len = tex.length;
		document.getElementById('limit').innerHTML = "Count : "+len;
			}
</script>
<form name="adminForm" enctype="multipart/form-data" method="post"  onmousemove="limiter()" >
	<input type='hidden' name='task' />
	<input type='hidden' name='add_edit' value='true' />
	<input type='hidden' name='id' value='<?php echo $this->id?>' />
	<input type='hidden' name='dvql_id' value='<?php echo $this->id?>' />
	<input type='hidden' name='dvql_hinhanh' value='<?php echo $imageurl; ?>' />
	<fieldset>
		<legend><?php echo JText::_('đơn vị quản lý')?></legend>
		<table class="admintable">
			<tr>
				<td class="key"><?php echo JText::_('Hình ảnh')?></td>
				<td> 
		     	<?php echo '<img width="120" height="120" src="../administrator/components/com_svquanlycanbo/uploads/'.$imageurl.'" alt="svbongda" />'; ?>
		     	<br />
		     	<input type="file" name="file" id="file" /> 
				<input type="submit"  value="Submit" onclick="document.adminForm.submit();" />
		     	</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Tên')?></td>
				<td>
					<input  onkeyup="limiter()" style="width:250px;" type="text" name="dvql_ten" value="<?php echo $object->dvql_ten;?>" />
					<b style="color:red;text-align:center;" id="loiten"  ></b>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Địa chỉ')?></td>
				<td>
					<input  onkeyup="limiter()" style="width:250px;" type="text" name="dvql_diachi" value="<?php echo $object->dvql_diachi;?>" />
					<b style="color:red;text-align:center;" id="loidiachi"  ></b>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Số điện thoại')?></td>
				<td>
					<input  onkeyup="limiter()" style="width:250px;" type="text" name="dvql_dienthoai" value="<?php echo $object->dvql_dienthoai;?>" />
					<b style="color:red;text-align:center;" id="loiphone"  ></b>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Website')?></td>
				<td><input  onkeyup="limiter()" style="width:250px;" type="text" name="dvql_website" value="<?php echo $object->dvql_website;?>" /></td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Email')?></td>
				<td>
					<input  onkeyup="limiter()" style="width:250px;" type="text" name="dvql_email" value="<?php echo $object->dvql_email;?>" />
					<b style="color:red;text-align:center;" id="loi"  ></b>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('Miêu tả')?></td>
				<td>
				<b style="color:blue;width:200px;text-align:center;" id="limit"  ></b><br/>
				<textarea name="dvql_mieuta" onkeyup="limiter()" rows="10" cols="50" ><?php echo $object->dvql_mieuta;?></textarea>
					<?php 
					$ed = &JFactory::getEditor();
					//echo $ed->display('comment',$donvi->dvql_mieuta,600,300,6,array());
					?>
				</td>
			</tr>
		</table>
	</fieldset>
</form>